package com.wyp168.juc;

/**
 * @ClassName InheritableThreadLocalDemo001
 * @Description TODO
 * @Author wyp168
 * @Date 2022/7/11 13:53
 */
public class InheritableThreadLocalDemo001 {
    public static void main(String[] args) {
        ThreadLocal<String> threadLocal = new InheritableThreadLocal<>();

        threadLocal.set("this is main threadLocal value");

        Thread thread = new Thread((() -> {
            System.out.println("子线程中获取到的父线程中的ThreadLocal中的变量值为： " + threadLocal.get());
        }));

        thread.start();

        System.out.println("父线程中获取到的ThreadLocal中的变量值为： " + threadLocal.get());
    }
}
